package hanshunping.project.chatRoom.chatServer.server.service;


import java.util.HashMap;
import java.util.Iterator;

/**
 * create by: 蔡博
 * description: TODO
 * create time: 2022/11/17 20:01
 * 该类用于管理和客户端通信的线程
  * @Param: null
 * @return
 * */
public class ManageConnectThread {
    //key id     value 线程
    private static HashMap<String, ConnectThread> hm = new HashMap<>();
    public static void addThread(String uid, ConnectThread ct){
        hm.put(uid,ct);
    }
    public static ConnectThread getThread(String uid){
        return hm.get(uid);
    }
    public static String getOnlines(){
        Iterator<String> itr = hm.keySet().iterator();
        String onlines = "";
        while (itr.hasNext()){
            onlines+=(itr.next()+" ");
        }
        return onlines;
    }
    public static void removeThread(String uid) {
        hm.remove(uid);
    }
}
